home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /***************************************************************************
- *
- * @(#) - BZ - Multiplayer tank game - Screen scaling.
- *
- * $Id: bzscreen.c,v 1.6 1993/08/11 19:46:18 adele Exp $
- *
- * Chris Fouts - Silicon Graphics, Inc.
- * October, 1991
- **************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <Xm/Xm.h>
- #include <X11/Xirisw/GlxMDraw.h>
- #include <gl/gl.h>
- #include <invent.h>
- #include "bz.h"
- #define BZSCREEN_INTERNAL
- #include "bzscreen.h"
-
- /* BEGIN PROTOTYPES -S bzscreen.c */
- static void check_graphics_hw( void ) ;
- /* END PROTOTYPES -S bzscreen.c */
-
- static char *version_id = "$Id: bzscreen.c,v 1.6 1993/08/11 19:46:18 adele Exp $" ;
-
- DECLARE( MVIEW ) ;
- DECLARE( RADAR ) ;
- DECLARE( HEAD ) ;
- DECLARE( LOADM ) ;
- DECLARE( READY ) ;
- DECLARE( SCORE ) ;
- DECLARE( LIVES ) ;
- DECLARE( LEVEL ) ;
- DECLARE( NOPLY ) ;
- DECLARE( RIGHT ) ;
- DECLARE( LEFTT ) ;
- DECLARE( MESGS ) ;
- DECLARE( OUTMS ) ;
- DECLARE( GROND ) ;
- DECLARE( LOGOD ) ;
- DECLARE( MINES ) ;
- DECLARE( FLAGS ) ;
-
- extern long screen_w ;
- extern long screen_h ;
- extern Boolean db_base ;
- extern Boolean mv_RGB ;
- extern Boolean transparentExplosion ;
- extern Boolean use_textures ;
-
-
- float digit_sx ;
- float digit_sy ;
-
- void get_screen_dimensions( void )
- {
- check_graphics_hw() ;
-
- screen_w = getgdesc( GD_XPMAX ) ;
- screen_h = getgdesc( GD_YPMAX ) ;
- #if defined(DEBUG)
- if( getenv( "BZ_SMALL_SCREEN" ) ) {
- screen_w = 1024 ;
- screen_h = 768 ;
- }
- #endif /* defined(DEBUG) */
-
- #if defined(INDIGO) || defined(SMALL_SCREEN)
- screen_w = 1024 ;
- screen_h = 768 ;
- #endif /* defined(INDIGO) || defined(SMALL_SCREEN) */
-
- /*
- * Determine whether or not to use a single buffer base.
- */
- if( getgdesc( GD_BITS_NORM_DBL_CMODE ) < 8 ) {
- db_base = FALSE ;
- /*
- * Determine whether or not to use a single buffer base.
- */
- if( getgdesc( GD_BITS_NORM_SNG_CMODE ) < 8 ) {
- fprintf( stderr, "\n\nSorry, not enough bitplanes. You need to be"
- " able to run either\ndouble-buffered RGB mode or"
- " double-buffered colormap mode with\nat least 4 bits"
- " per buffer\n\n" ) ;
- end_program( 1 ) ;
- }
- }
- else {
- db_base = TRUE ;
- }
-
- /*
- * Determine whether or not to use RGB mode in the main view.
- */
- if( getgdesc( GD_BITS_NORM_DBL_RED ) < 1 ) {
- mv_RGB = FALSE ;
- transparentExplosion = FALSE ;
- use_textures = FALSE ;
- }
- else {
- mv_RGB = TRUE ;
- }
-
- #if defined(INDIGO)
- db_base = FALSE ;
- transparentExplosion = FALSE ;
- #endif /* defined(INDIGO) */
- }
-
-
- void set_up_screen_dimensions( void )
- {
- float w ;
- float h ;
- float x_off = 0.f ;
-
- w = (float)screen_w - 1.f ;
- if( 4 * screen_h == 3 * screen_w ) {
- h = (float)screen_h - 1.f ;
- }
- else {
- h = 0.75f * (float)screen_w - 1.f ;
- }
-
- SETUP( MVIEW ) ;
- VPMVIEW_L = FRAMEW ;
- VPMVIEW_R = screen_w - FRAMEW ;
- VPMVIEW_T = screen_h - FRAMEW ;
- FSETUP( MVIEW ) ;
- SETUP( RADAR ) ;
- SETUP( HEAD ) ;
- SETUP( LOADM ) ;
- SETUP( READY ) ;
- SETUP( SCORE ) ;
- SETUP( LIVES ) ;
- SETUP( LEVEL ) ;
- SETUP( NOPLY ) ;
- SETUP( RIGHT ) ;
- SETUP( LEFTT ) ;
- SETUP( MESGS ) ;
- SETUP( OUTMS ) ;
- SETUP( GROND ) ;
- SETUP( LOGOD ) ;
- SETUP( MINES ) ;
- SETUP( FLAGS ) ;
- VPLOGOD_L = VPLOGOD_R - ( VPLOGOD_T - VPLOGOD_B ) ;
- VPGROND_L = VPMVIEW_L ;
- VPGROND_R = VPMVIEW_R ;
- VPGROND_T = ( VPMVIEW_B + VPMVIEW_T ) / 2 ;
- FSETUP( GROND ) ;
-
- digit_sx = w / 1023.f ;
- digit_sy = h / 767.f ;
- }
-
-
-
- static void check_graphics_hw( void )
- {
- inventory_t *base ;
- inventory_t *inv ;
-
- /*
- * I do this because there is no way to determine via getgdesc if there
- * is texture mapping is done in hardware or software. I don't want it
- * on if the texture mapping is done in software for obvious reasons.
- * It does require me to update this file when new hardware comes out,
- * though. However, the game runs just as well without texturing, so
- * it's no big deal if it's not there.
- */
- inv = base = getinvent() ;
- while( inv != NULL ) {
- #if defined( SVR3 )
- switch( inv->class ) {
- case INV_GRAPHICS :
- switch( inv->type ) {
- #else
- switch( inv->inv_class ) {
- case INV_GRAPHICS :
- switch( inv->inv_type ) {
- #endif /* defined( SVR3 ) */
- case INV_VGX :
- case INV_VGXT :
- case INV_RE :
- #ifdef INV_VTX
- case INV_VTX :
- #endif /* INV_VTX */
- use_textures = TRUE ;
- transparentExplosion = TRUE ;
- break ;
- case INV_GR2 : /* Express graphics */
- use_textures = FALSE ;
- transparentExplosion = TRUE ;
- break ;
- default :
- use_textures = FALSE ;
- transparentExplosion = FALSE ;
- break ;
- }
- break ;
-
- default :
- break ;
- }
- inv = getinvent() ;
- }
-
- if( base )
- endinvent() ;
-
- return ;
- }
-
-